﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfLussen
{
    /// <summary>
    /// Interaction logic for WpfDelers.xaml
    /// </summary>
    public partial class WpfDelers : Window
    {
        public WpfDelers()
        {
            InitializeComponent();
        }

        private void btnDelers_Click(object sender, RoutedEventArgs e)
        {
            int bovenGrens = Convert.ToInt32(txtBovenGrens.Text);
            if (bovenGrens > 1000)
            {
                MessageBox.Show("Te groot!");
                return;
            }

            for (int huidigGetal = 1; huidigGetal <= bovenGrens; huidigGetal++)
            {
                string delers = "";
                int aantalDelers = 0;
                for (int controleerGetal = 1; controleerGetal <= huidigGetal; controleerGetal++)
                {
                    if (huidigGetal % controleerGetal == 0)
                    {
                        delers += controleerGetal + " ";
                        aantalDelers++;
                    }
                }


                if (aantalDelers == 2) delers += " priemgetal!";

                lbDelers.Items.Add(huidigGetal +" :" +delers);
            }
        }
    }
}
